using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_Default2 : System.Web.UI.Page
{
    protected clsCategory cat;
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        cat = new clsCategory();
        int id = Convert.ToInt32(Request.QueryString["id"].ToString());
        if (id > 0)
        {
            deleteChildrenCategory(id);
            Response.Redirect("./DanhMucSanPham.aspx");
        }
    }

    private void deleteChildrenCategory(int ID)
    {
        DataTable tblChildren = cat.getlistChildren(ID);
        int i = 0;
        while (i < tblChildren.Rows.Count)
        {
            deleteChildrenCategory(Convert.ToInt32(tblChildren.Rows[i][0].ToString()));
            cat.deleteItem(Convert.ToInt32(tblChildren.Rows[i][0].ToString()));
            i++;
        }
        cat.deleteItem(ID);
    }
}
